package com.kotlin.hxh.ui.fragment.second.child

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.kotlin.hxh.R
import com.kotlin.hxh.adapter.ZhihuPagerFragmentAdapter
import com.kotlin.hxh.base.BaseMainFragment
import kotlinx.android.synthetic.main.zhihu_fragment_second_pager.*


/**
 * @author huxh
 * @date 2018/12/19.
 */

/**
 * Created by YoKeyword on 16/6/5.
 */
class ViewPagerFragment : BaseMainFragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) = inflater.inflate(R.layout.zhihu_fragment_second_pager, container, false)

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
    }

    private fun initView() {
        tab.addTab(tab.newTab())
        tab.addTab(tab.newTab())
        tab.addTab(tab.newTab())
        viewPager.adapter = ZhihuPagerFragmentAdapter(childFragmentManager,
                getString(R.string.recommend), getString(R.string.hot), getString(R.string.favorite),
                getString(R.string.more))
        tab.setupWithViewPager(viewPager)
    }

    companion object {

        fun newInstance(): ViewPagerFragment {

            val args = Bundle()

            val fragment = ViewPagerFragment()
            fragment.arguments = args
            return fragment
        }
    }
}
